<?php
$redis = new Redis();

try {
    //192.168.171.19 是宿主机的ip，1479是端口映射redis服务器的1379端口
    $redis->connect(redis,1379);

    $redis->connect('192.168.171.19',1479);

    // var_dump($redis);
    $redis->auth('123456');
    $ping = $redis->ping();
    printf("Redis server is running: %s <br>",$ping);

    $key = "test_key";
    //设置 redis 字符串数据
    $redis->set($key, "Redis tutorial ".date('Y-m-d H:i:s'));
    // 获取存储的数据并输出
    echo "Stored string in redis:: " . $redis->get($key);

} catch (RedisException $e) {
    echo $e->getMessage();
}

include "common.php";

